﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPF.DAAB.Client.Classes;

namespace WPF.DAAB.Client
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void btnContar_Click(object sender, RoutedEventArgs e)
        {
            this.txtCantidadPersonas.Text = PersonaRepository.Instance.ContarPersonas().ToString();
        }

        private void btnListar_Click(object sender, RoutedEventArgs e)
        {
            this.cboLista.ItemsSource = PersonaRepository.Instance.ListarPersonas();
        }

        private void btnLeer_Click(object sender, RoutedEventArgs e)
        {
            this.spPersona.DataContext = PersonaRepository.Instance.ObtenerPersona((int)this.cboLista.SelectedValue);
        }

        private void btnActualizar_Click(object sender, RoutedEventArgs e)
        {
            PersonaRepository.Instance.ActualizarPersona((Persona)this.spPersona.DataContext);
        }
    }
}
